package checker;

import util.AST.AST;
import util.AST.Program;
import util.AST.Comand.Comand;
import util.AST.Comand.FunctionDeclaration;
import util.AST.Comand.ProcedureDeclaration;
import util.AST.Comand.VarDeclaration;
import util.AST.AsgComd.AsgComd;
import util.AST.AsgComd.AsgComdExp;
import util.AST.AsgComd.AsgComdFuncCall;
import util.AST.Expression.BinaryExpression;
import util.AST.Expression.Expression;
import util.AST.Expression.IdUnaryExpression;
import util.AST.Expression.NumberUnaryExpression;
import util.AST.Expression.UnaryExpression;
import util.AST.Statement.AssignStatement;
import util.AST.Statement.ExitStatement;
import util.AST.Statement.FunctionCallStatement;
import util.AST.Statement.IfElseStatement;
import util.AST.Statement.PutLineStatement;
import util.AST.Statement.ReturnStatement;
import util.AST.Statement.Statement;
import util.AST.Statement.WhileStatement;
import util.AST.Terminal.ID;
import util.AST.Terminal.Number;
import util.AST.Terminal.Operator;
import util.AST.Terminal.Terminal;
import util.AST.Terminal.Tipo;
import util.AST.Terminal.Value;
import util.symbolsTable.IdentificationTable;

public class Checker implements Visitor {
	private IdentificationTable identificationTable;
	
	public Checker(){
		identificationTable = new IdentificationTable();
	}
	
	public void check(AST a) throws SemanticException{
		a.visit(this,null);
	}

	public Object visitProgram(Program p, Object o){
		AST a = identificationTable.retrieve(p.id);
		if(a!=null){
			//TODO erro
		}
		identificationTable.enter(p.id, p);
		p.id.visit(this,o);
			
	}
	
	public Object visitID(ID i, Object o){
		Object a = identificationTable.retrieve(i);
		if(a==null){
			//TODO erro
		}
		i.declaration = a;
	}
	
}
